<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <script th:src="@{/static/js/jquery-3.3.1.js}"></script>
    <link rel="stylesheet" th:href="@{/static/lib/bootstrap-3.3.7-dist/css/bootstrap.min.css}">
    <script th:src="@{/static/lib/bootstrap-3.3.7-dist/js/bootstrap.min.js}"></script>
    <link rel="stylesheet" th:href="@{/static/css/header.css}">
    <title>Title</title>
</head>
<body>
<nav th:fragment="navbar" class="navbar navbar-default navbar-inverse">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#" th:href="@{/}">Learning</a>
            <a class="navbar-brand" href="#" th:href="@{/cource/allCource}">全部课程</a>
        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div th:if="${session.user} == null" class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav navbar-right">

                <li><a href="#" th:href="@{/user/register}">注册</a></li>
                <li><a href="#" th:href="@{/user/login}">登陆</a></li>
            </ul>
        </div><!-- /.navbar-collapse -->
        <div th:if="${session.user} != null" class="collapse navbar-collapse" th:id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav navbar-right">
                <li>
                    <div class="dropdown">
                        <input type="hidden" th:value="${session.user.id}" id="getUserId">
                        <button th:utext="${session.user.username}" id="dLabel" type="button" data-toggle="dropdown"
                                aria-haspopup="true" aria-expanded="false" class="btn btn-default">
                            user
                            <span class="caret"></span>
                        </button>
                        <ul th:if="${session.user.username} != 'admin'" class="dropdown-menu" aria-labelledby="dLabel">
                            <li><a href="#" th:href="@{/user/userInfo}">个人资料</a></li>
                            <li><a href="#" th:href="@{/user/toUpload}">课程上传</a></li>
                            <li><a href="#" th:href="@{/user/toMyCource}">我的课程</a></li>
                            <li><a href="#" th:href="@{/user/studyingCource}">订阅的课程</a></li>
                            <li><a href="#" th:href="@{/user/loginOut}">登出</a></li>
                        </ul>
                        <ul th:if="${session.user.username} == 'admin'" class="dropdown-menu" aria-labelledby="dLabel">
                            <li><a href="#" th:href="@{/user/adminAllCource}">所有课程</a></li>
                            <li><a href="#" th:href="@{/user/adminCarousel}">轮播图</a></li>
                            <li><a href="#" th:href="@{/user/loginOut}">登出</a></li>
                        </ul>
                    </div>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
</body>
</html>